package com.ruoyi.project.fire.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.framework.aspectj.lang.annotation.Log;
import com.ruoyi.framework.aspectj.lang.enums.BusinessType;
import com.ruoyi.project.fire.domain.FireDormitory;
import com.ruoyi.project.fire.service.IFireDormitoryService;
import com.ruoyi.framework.web.controller.BaseController;
import com.ruoyi.framework.web.domain.AjaxResult;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.framework.web.page.TableDataInfo;

/**
 * 寝室消息管理Controller
 * 
 * @author 布衣
 * @date 2025-05-13
 */
@RestController
@RequestMapping("/system/dormitory")
public class FireDormitoryController extends BaseController
{
    @Autowired
    private IFireDormitoryService fireDormitoryService;

    /**
     * 查询寝室消息管理列表
     */
    @PreAuthorize("@ss.hasPermi('system:dormitory:list')")
    @GetMapping("/list")
    public TableDataInfo list(FireDormitory fireDormitory)
    {
        startPage();
        List<FireDormitory> list = fireDormitoryService.selectFireDormitoryList(fireDormitory);
        return getDataTable(list);
    }

    /**
     * 导出寝室消息管理列表
     */
    @PreAuthorize("@ss.hasPermi('system:dormitory:export')")
    @Log(title = "寝室消息管理", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, FireDormitory fireDormitory)
    {
        List<FireDormitory> list = fireDormitoryService.selectFireDormitoryList(fireDormitory);
        ExcelUtil<FireDormitory> util = new ExcelUtil<FireDormitory>(FireDormitory.class);
        util.exportExcel(response, list, "寝室消息管理数据");
    }

    /**
     * 获取寝室消息管理详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:dormitory:query')")
    @GetMapping(value = "/{dormitoryId}")
    public AjaxResult getInfo(@PathVariable("dormitoryId") Long dormitoryId)
    {
        return success(fireDormitoryService.selectFireDormitoryByDormitoryId(dormitoryId));
    }

    /**
     * 新增寝室消息管理
     */
    @PreAuthorize("@ss.hasPermi('system:dormitory:add')")
    @Log(title = "寝室消息管理", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody FireDormitory fireDormitory)
    {
        return toAjax(fireDormitoryService.insertFireDormitory(fireDormitory));
    }

    /**
     * 修改寝室消息管理
     */
    @PreAuthorize("@ss.hasPermi('system:dormitory:edit')")
    @Log(title = "寝室消息管理", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody FireDormitory fireDormitory)
    {
        return toAjax(fireDormitoryService.updateFireDormitory(fireDormitory));
    }

    /**
     * 删除寝室消息管理
     */
    @PreAuthorize("@ss.hasPermi('system:dormitory:remove')")
    @Log(title = "寝室消息管理", businessType = BusinessType.DELETE)
	@DeleteMapping("/{dormitoryIds}")
    public AjaxResult remove(@PathVariable Long[] dormitoryIds)
    {
        return toAjax(fireDormitoryService.deleteFireDormitoryByDormitoryIds(dormitoryIds));
    }
}
